<?php
include ("conn/conn.php");
$username = $_POST ["username"];
$userpwd = md5 ( $_POST ["userpwd"] );
class chkinput {
	var $name;
	var $pwd;
	function chkinput($x, $y) {
		$this->name = $x;
		$this->pwd = $y;
	}
	function checkinput() {
		include ("conn/conn.php");
		$sql = mysqli_query ( $conn, "select * from tb_user where name='" . $this->name . "'" );
		$info = mysqli_fetch_array ( $sql, MYSQLI_ASSOC );
		
		if ($info == false) {
			echo "<script language='javascript'>alert('不存在此用户！');history.back();</script>";
			exit ();
		} else {
			if ($info ["dongjie"] == 1) {
				echo "<script language='javascript'>alert('该用户已经被冻结！');history.back();</script>";
				exit ();
			}
			
			if ($info ["pwd"] == $this->pwd) {
				session_start ();
				$_SESSION ["username"] = $info ["name"];
				$_SESSION ["producelist"] = "producelist";
				$producelist = "";
				$_SESSION ["quatity"] = "quatity";
				$quatity = "";
				header ( "location:index.php" );
				exit ();
			} else {
				echo "<script language='javascript'>alert('密码输入错误！');history.back();</script>";
				exit ();
			}
		}
	}
}

$obj = new chkinput ( trim ( $username ), trim ( $userpwd ) );
$obj->checkinput ();
?>